package Javafoundation;

import java.util.Scanner;

public class Neighnour {
    public static void main(String[] args) {
        int[][]  dig = new int[5][5];
        int i ;
        int j = 0;
        int[] a= new int[5];
        int[] b= new int[5];

        for(i=0;i<5;i++){
            for(j=0;j<5;j++){
                a[i]=0;
                b[i]=0;
                dig[i][j]=-1;
            }
        }

        Scanner scan  =  new Scanner(System.in);
        j=0;
        System.out.println("这个是无向图");
        for(i=0;i<5;i++){
            System.out.println("请输入第一个： ");
            int input0 = scan.nextInt();
            dig[i][j] = input0;
            for(j=1;;j++){
                System.out.println("是否有下一个接点？");
                String kong = scan.nextLine();
                char yn = scan.next().charAt(0);
                if(('Y' == yn)||(yn == 'y')){
                    String kong2 = scan.nextLine();
                    int input = scan.nextInt();
                    dig[i][j] = input;
                    a[i]++;
                }
                else{
                    j=0;
                    break;
                }

            }
        }
        for(int k=0;k<5;k++) {
            for(j=0;j<5;j++){
                for(i=0;dig[j][i]!=-1;i++){
                    if(dig[j][i]==k)
                        b[k]++;
                }
            }
        }
        System.out.println("请输出出度：");
        for(i=0;i<5;i++)
            System.out.println(a[i]+1);
        System.out.println("请输出入度：");
        for(i=0;i<5;i++)
            System.out.println(b[i]);
    }
}
